<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ attribute name="page" type="java.lang.Integer" required="true"%>
<%@ attribute name="count" type="java.lang.Integer" required="true"%>
<%@ attribute name="curpage" type="java.lang.Integer" required="true"%>
<%@ attribute name="formId" type="java.lang.String" required="false"%>
<c:if test="${formId != null && formId != ''}">
<script type="text/javascript">
var ${formId} = null;
$(function(){
	${formId} = $("#${formId}").clone();
	${formId}.css("display", "none");
});
function ${formId}_page(curpage) {
	if (${formId} != null) {
		${formId}.append("<input name='curpage' value='" + curpage + "'/>");
		//for firefox
		$(document.body).append(${formId});
		${formId}.submit();
	}
}
</script>
</c:if>
<c:if test="${page > 1}">
	<div class="pagination">
	    <ul>
	        <c:if test="${curpage > 1}">
	        	<c:choose>
					<c:when test="${formId != null && formId != ''}">
						<li><a href="javascript:${formId}_page(1);">&lt;&lt;</a></li>
		   				<li><a href="javascript:${formId}_page(${curpage - 1});">&lt;</a></li>
					</c:when>
					<c:otherwise>
						<li><a href="?curpage=1">&lt;&lt;</a></li>
		   				<li><a href="?curpage=${curpage - 1}">&lt;</a></li>
					</c:otherwise>
				</c:choose>
		   	</c:if>
		   	<c:forEach begin="${curpage < 7 ?  1 : curpage - 7}" end="${curpage - 1}" var="i">
		   		<c:if test="${i > 0}">
		   			<c:choose>
						<c:when test="${formId != null && formId != ''}">
							<li><a href="javascript:${formId}_page(${i});">${i}</a></li>
						</c:when>
						<c:otherwise>
							<li><a href="?curpage=${i}">${i}</a></li>
						</c:otherwise>
					</c:choose>
		   		</c:if>
		   	</c:forEach>
	    	<li><a style="color:#000;">${curpage}</a></li>
	    	<c:forEach begin="${curpage + 1}" end="${curpage + 7}" var="i">
		   		<c:if test="${i <= page}">
		   			<c:choose>
						<c:when test="${formId != null && formId != ''}">
							<li><a href="javascript:${formId}_page(${i});">${i}</a></li>
						</c:when>
						<c:otherwise>
							<li><a href="?curpage=${i}">${i}</a></li>
						</c:otherwise>
					</c:choose>
		   		</c:if>
		   	</c:forEach>
		    <c:if test="${curpage < page}">
		   		<c:choose>
					<c:when test="${formId != null && formId != ''}">
						<li><a href="javascript:${formId}_page(${curpage + 1});">&gt;</a></li>
		   				<li><a href="javascript:${formId}_page(${page});">&gt;&gt;</a></li>
					</c:when>
					<c:otherwise>
						<li><a href="?curpage=${curpage + 1}">&gt;</a></li>
		   				<li><a href="?curpage=${page}">&gt;&gt;</a></li>
					</c:otherwise>
				</c:choose>
		   	</c:if>
	    </ul>
	</div>
</c:if>
<c:if test="${count == 0}">
	<div class="alert alert-danger">
       	No data found
   	</div>
</c:if>